feat: add sequence operator types for event sequencing (A THEN B) #50
Conversation
| * "condition": { "operator": "equal", "left": { "model": "events", "path": "name" }, "right": "purchase" } | ||
| * } | ||
| */ | ||
| export type SequenceOperand = { |
There was a problem hiding this comment.
leave this in a separate file sequence-operand.ts and add it to the operand.ts type
There was a problem hiding this comment.
something in the order of:
export type Operand =
boolean
| number
| string
| DateOperand
| ModelPath
| ModelOperand
| AudienceOperand
| SequenceOperand
I think you need to run one of the scripts to write a new schema version from the new .ts files. Start with the README and lmk if you need more help. |
| "declarationDir": "dist", | ||
| "declarationMap": false | ||
| "declarationMap": false, | ||
| "emitDeclarationOnly": true |
There was a problem hiding this comment.
maybe a question for Oleg or a code reviewer with more context?
There was a problem hiding this comment.
what was the reason for adding this?
| operator: LogicalOperator | ||
|
|
||
|
|
||
| class Expression1(BaseModel): |
There was a problem hiding this comment.
This needs to be properly named. I believe Kevin was using this to patch up code gen https://github.com/mParticle/audience-sdk/blob/main/sdk/typescript-schema/scripts/add_titles_to_schema.sh
There was a problem hiding this comment.
@AustinFash add
$.definitions.Expression.anyOf[3]|SequenceExpression to that file after line 24
| * 1. Reference event1's timestamp: | ||
| * { alias: "event1", path: "timestamp" } | ||
| */ | ||
| export type AliasPath = { |
There was a problem hiding this comment.
does it only apply to dates? Reads like it shouldn't be in this file
There was a problem hiding this comment.
No, this applies to any generic "alias" but we are using it only for the Event Sequencing use case as of now. We are defining an alias as a CTE to represent a qualified Event (qualified Event meaning the Event data model and any other conditions that specify which Events qualify). Then the path from that alias would be QualifiedEvent.Path (modeled after ModelPath)
There was a problem hiding this comment.
lets move it to the appropriate file where the model path defined
# [1.5.0](https://github.com/mParticle/audience-sdk/compare/audience-typescript-schema@1.4.2...audience-typescript-schema@1.5.0) (2026-03-10) ### Features * add sequence operator types for event sequencing (A THEN B) ([#50](#50)) ([cebde5a](cebde5a))
|
🎉 This PR is included in version 1.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Background
This blocks common funnel use cases (e.g., conversion funnels, activation steps).
Composable Audience Event Sequencing Criteria v1 tech spec.
What Has Changed
sdk/typescript-schema/common/operator.ts: AddedSequenceOperatortype ("then") to represent the new sequence operator alongside existinglogical/binary/unary operators.
sdk/typescript-schema/operand/date-operand.ts: AddedAliasPathtype to reference a named step's field (e.g.,{ alias: "event1", path: "timestamp" }). ExtendedRelativeDatewith optionalrelative_to?: AliasPathto allow Step B's recency window to be anchored relative to Step A'stimestamp rather than the evaluation timestamp.
sdk/typescript-schema/expression/expression.ts: AddedSequenceOperandtype (a single step withalias,operand: ModelPath, and optionalcondition: Expression) and extended theExpressionunion type with athenvariant ({ operator: SequenceOperator, sequence: SequenceOperand[] }).sdk/typescript-schema/index.ts: ExportedModelPathfrom the public index (previously unexported, now required asSequenceOperanduses it asa public type).
Screenshots/Video
N/A — type-only change.
Checklist
Additional Notes
sequencearray on thethenexpression accepts any number of operands at the type level. V1 restricts sequences to exactly 2 steps (A THEN B),but this constraint is enforced in the UI and validation layer — not in the type definition — so that expanding to N-step sequences in future only
requires a validation change, not a schema change.
relative_tofield onRelativeDateis optional and backward-compatible; existing audience definitions without sequencing are unaffected.SequenceOperator.cs), and UI affordances.Reference Issue (For employees only. Ignore if you are an outside contributor)